<template>
  <div>
    <Card>
      <Tables ref="tables" searchable search-place="top" :loading="listLoading" :columns="columns" v-model="list">
        <template slot="handleButton">
          <span>&nbsp;</span>
        </template>
        <template slot="searchButton">
          <div style="float:right">
            <Input placeholder="操作人姓名" class="search-input" v-model="listQuery.crtName">
            <Button @click="getList" slot="append" type="info" icon="ios-search"></Button>
            </Input>
          </div>
        </template>
      </Tables>
      <div style="margin: 10px;overflow: hidden">
        <div style="float: left;">
          <Page v-show="!listLoading" :total="total" :page-size-opts="[50,100,500,1000,2000]" :current="listQuery.page" show-total show-sizer :page-size="listQuery.limit" @on-change="handleCurrentChange" @on-page-size-change="handleSizeChange"></Page>
        </div>
      </div>
    </Card>
  </div>
</template>
<script>
import Tables from '_c/tables'
import { mapGetters } from 'vuex'
import {
  page
} from '@/api/admin/gateLog/index'
export default {
  name: 'gateLog',
  components: {
    Tables
  },
  data () {
    return {
      tenantManager_btn_add: false,
      tenantManager_btn_frozen: false,
      listLoading: false,
      total: 0,
      list: [],
      current: 1,
      listQuery: {
        page: 1,
        limit: 50,
        crtName: undefined
      },
      columns: [
        { title: '菜单', key: 'menu' },
        { title: '操作', key: 'opt' },
        { title: '资源路径', key: 'uri' },
        { title: '操作时间', key: 'crtTime' },
        { title: '操作人ID', key: 'crtUserId' },
        { title: '操作人', key: 'crtUserName' },
        { title: '操作主机', key: 'crtHost' }
      ]
    }
  },
  computed: {
    ...mapGetters([
      'elements'
    ])
  },
  created () {
  },
  methods: {
    handleSizeChange (val) {
      this.listQuery.limit = val
      this.getList()
    },
    getList () {
      this.listLoading = true
      page(this.listQuery).then(response => {
        this.list = response.data.rows
        this.total = response.data.total
        this.listLoading = false
      })
    },
    handleCurrentChange (val) {
      this.listQuery.page = val
      this.getList()
    }
  }
}
</script>
